package gui.tools;

import java.awt.event.KeyEvent;

import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;

/**
 * Setting up the menubar for the program
 * 
 * @author: Kjartan Elias, Eirik Vigeland
 * @version: %I%, %G%
 */
public class Menu extends JMenuBar {

	private static final long serialVersionUID = 1L;
	private JMenu file, edit, help;
	private JMenuItem exit, about;
	private ActionHandler ac;

	/**
	 * The constructor for the menu-bar, which gets the action listener for
	 * managing events.
	 * 
	 * @param ac
	 *            ActionHandler - For managing events
	 */
	public Menu(ActionHandler ac) {
		this.ac = ac;
		setMenuBar();
	}

	/**
	 * Sets the objects and actions of the menu-bar. This method is called by
	 * the constructor.
	 */
	private void setMenuBar() {

		// FILE
		file = new JMenu("File");
		file.setMnemonic(KeyEvent.VK_F);
		exit = new JMenuItem("Exit");
		exit.addActionListener(ac);
		file.add(exit);
		add(file);

		// EDIT
		edit = new JMenu("Edit");
		edit.setMnemonic(KeyEvent.VK_E);
		add(edit);

		// HELP
		help = new JMenu("Help");
		about = new JMenuItem("About");
		about.addActionListener(ac);
		help.add(about);
		about.getAccessibleContext().setAccessibleDescription(
				"Opens the program "
						+ "version and information in a new window");
		help.setMnemonic(KeyEvent.VK_H);
		add(help);
	}

}
